package com.boolib.shopweb.web;

import com.boolib.commons.entity.ServerResponse;

import com.boolib.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shop/category")
public class CategoryController {



    @Autowired
    private ICategoryService iCategoryService;



    @RequestMapping("/findAll")
    public ServerResponse findAll(){
        return  iCategoryService.selectAll();
    }


    @RequestMapping("/findTree")
    public ServerResponse selectCategoryTree(){
        return  iCategoryService.selectCategoryTree();
    }



    @RequestMapping("/selectBrothers")
    public ServerResponse selectBrothers(Integer id){
        return  iCategoryService.selectBrothers(id);
    }

    @RequestMapping("/selectAllNormal")
    public ServerResponse selectAllNormal(
            @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
            @RequestParam(value = "pageSize" ,defaultValue = "10")Integer pageSize){
        return  iCategoryService.selectAllNormal(pageNum,pageSize);
    }


    @RequestMapping("/selectParents")
    public ServerResponse selectParents(Integer id){
        return  iCategoryService.selectParents(id);
    }

    @RequestMapping("/selectChildren")
    public ServerResponse selectChildren(Integer id){
        return  iCategoryService.selectChildren(id);
    }


    @RequestMapping("/queryOne")
    public ServerResponse queryOne(Integer id){
        return  iCategoryService.selectOneNormal(id);
    }







}
